{
  "cells": [
    {
      "cell_type": "code",
      "execution_count": null,
      "metadata": {
        "pycharm": {}
      },
      "outputs": [],
      "source": "from build_docker import *\nimport unittest\nimport pprint\n\nDEBUG_MODE \u003d True\n\nthis_script_path \u003d os.path.realpath(\u0027__file__\u0027)\n\nTEST_BUILD_TAG \u003d \u0027mytest\u0027"
    },
    {
      "cell_type": "code",
      "execution_count": null,
      "metadata": {
        "pycharm": {}
      },
      "outputs": [],
      "source": [
        "# test if build chain can be constructed in desired order\n",
        "print( Project_Build.get_ordered_build_chain_single(\u0027manta\u0027) )\n",
        "print( Project_Build.get_ordered_build_chain_single(\u0027delly\u0027) )\n",
        "print( Project_Build.get_ordered_build_chain_single(\u0027melt\u0027) )\n",
        "print( Project_Build.get_ordered_build_chain_single(\u0027wham\u0027) )\n",
        "print( Project_Build.get_ordered_build_chain_single(\u0027sv-base-mini\u0027) )\n",
        "print()\n",
        "print( Project_Build.get_ordered_build_chain_single(\u0027sv-base\u0027) )\n",
        "print( Project_Build.get_ordered_build_chain_single(\u0027samtools-cloud\u0027) )\n",
        "print( Project_Build.get_ordered_build_chain_single(\u0027sv-pipeline\u0027) )\n",
        "print( Project_Build.get_ordered_build_chain_single(\u0027cnmops\u0027) )\n",
        "print()\n",
        "print( Project_Build.get_ordered_build_chain_single(\u0027sv-pipeline-rdtest\u0027) )\n",
        "print( Project_Build.get_ordered_build_chain_single(\u0027sv-pipeline-qc\u0027) )\n",
        "\n",
        "\n",
        "print( Project_Build.get_ordered_build_chain_list([\u0027manta\u0027]) )\n",
        "print( Project_Build.get_ordered_build_chain_list([\u0027delly\u0027]) )\n",
        "print( Project_Build.get_ordered_build_chain_list([\u0027melt\u0027]) )\n",
        "print( Project_Build.get_ordered_build_chain_list([\u0027wham\u0027]) )\n",
        "print( Project_Build.get_ordered_build_chain_list([\u0027sv-base-mini\u0027]) )\n",
        "print()\n",
        "print( Project_Build.get_ordered_build_chain_list([\u0027sv-base\u0027]) )\n",
        "print( Project_Build.get_ordered_build_chain_list([\u0027samtools-cloud\u0027]) )\n",
        "print( Project_Build.get_ordered_build_chain_list([\u0027sv-pipeline\u0027]) )\n",
        "print( Project_Build.get_ordered_build_chain_list([\u0027cnmops\u0027]) )\n",
        "print()\n",
        "print( Project_Build.get_ordered_build_chain_list([\u0027sv-pipeline-rdtest\u0027]) )\n",
        "print( Project_Build.get_ordered_build_chain_list([\u0027sv-pipeline-qc\u0027]) )\n",
        "\n",
        "\n",
        "print( Project_Build.get_ordered_build_chain_list([\u0027manta\u0027,\u0027delly\u0027,\u0027melt\u0027,\u0027wham\u0027,\u0027sv-base-mini\u0027]) )\n",
        "print( Project_Build.get_ordered_build_chain_list([\u0027sv-base\u0027,\u0027samtools-cloud\u0027,\u0027sv-pipeline\u0027,\u0027cnmops\u0027]) )\n",
        "print( Project_Build.get_ordered_build_chain_list([\u0027sv-pipeline-rdtest\u0027,\u0027sv-pipeline-qc\u0027]) )\n",
        "print( Project_Build.get_ordered_build_chain_list([\u0027manta\u0027, \u0027cnmops\u0027, \u0027sv-pipeline-rdtest\u0027,\u0027sv-pipeline-qc\u0027]) )\n"
      ]
    },
    {
      "cell_type": "code",
      "execution_count": null,
      "metadata": {
        "pycharm": {}
      },
      "outputs": [],
      "source": "# args for testing consistency check functionality\n        \n# illegal build target\nTEST_ARGS_FAIL_ILLEGAL_TARGET \u003d [\u0027--targets\u0027, \u0027manta\u0027, \u0027caller\u0027, \n                                 \u0027--image-tag\u0027, TEST_BUILD_TAG]\n\n# too many targets\nTEST_ARGS_FAIL_TOO_MANY_TARGET \u003d [\u0027--targets\u0027, \u0027all\u0027, \u0027manta\u0027, \n                                  \u0027--image-tag\u0027, TEST_BUILD_TAG]\n\n# forget to provide staging dir when building from remote source\nTEST_ARGS_FAIL_FORGOT_STAGING \u003d [\u0027--targets\u0027, \u0027all\u0027, \n                                 \u0027--image-tag\u0027, TEST_BUILD_TAG, \n                                 \u0027--remote-git-hash\u0027, \u00277d3795cf14ff9e414d632f7912584768d9c8a0e1\u0027]\n\n# mix remote and local build mode\nTEST_ARGS_FAIL_LOCAL_REMOTE_MIX \u003d [\u0027--targets\u0027, \u0027all\u0027, \n                                   \u0027--image-tag\u0027, TEST_BUILD_TAG, \n                                   \u0027--use-ssh\u0027]\n\n# update \"latest\" from local files, prohibitted\nTEST_ARGS_FAIL_NO_LATEST \u003d [\u0027--targets\u0027, \u0027all\u0027, \n                            \u0027--image-tag\u0027, TEST_BUILD_TAG, \n                            \u0027--dockerhub-root\u0027, \u0027shuangbroad\u0027,\n                            \u0027--update-latest\u0027]\n\nTEST_CASES \u003d (TEST_ARGS_FAIL_ILLEGAL_TARGET, \n              TEST_ARGS_FAIL_TOO_MANY_TARGET, \n              TEST_ARGS_FAIL_FORGOT_STAGING, \n              TEST_ARGS_FAIL_LOCAL_REMOTE_MIX, \n              TEST_ARGS_FAIL_NO_LATEST)\n\n##########\nif DEBUG_MODE:\n    for tt in TEST_CASES:\n        try:\n            test_parser \u003d CMD_line_args_parser(tt)\n        except UserError as e:\n            print(\"Successfully caught user error:\\n\" + str(e))\n        else:\n            raise RuntimeError(\"Failed to capture mistakes\")\n"
    }
  ],
  "metadata": {
    "kernelspec": {
      "display_name": "Python 3",
      "language": "python",
      "name": "python3"
    },
    "language_info": {
      "codemirror_mode": {
        "name": "ipython",
        "version": 3
      },
      "file_extension": ".py",
      "mimetype": "text/x-python",
      "name": "python",
      "nbconvert_exporter": "python",
      "pygments_lexer": "ipython3",
      "version": "3.7.3"
    },
    "varInspector": {
      "cols": {
        "lenName": 16,
        "lenType": 16,
        "lenVar": 40
      },
      "kernels_config": {
        "python": {
          "delete_cmd_postfix": "",
          "delete_cmd_prefix": "del ",
          "library": "var_list.py",
          "varRefreshCmd": "print(var_dic_list())"
        },
        "r": {
          "delete_cmd_postfix": ") ",
          "delete_cmd_prefix": "rm(",
          "library": "var_list.r",
          "varRefreshCmd": "cat(var_dic_list()) "
        }
      },
      "types_to_exclude": [
        "module",
        "function",
        "builtin_function_or_method",
        "instance",
        "_Feature"
      ],
      "window_display": false
    }
  },
  "nbformat": 4,
  "nbformat_minor": 2
}